﻿Imports Microsoft.Practices.EnterpriseLibrary.Data
Imports Seuss.EnterpriseLibrary.DataAccess
Imports Seuss.EnterpriseLibrary.BusinessLogic
Imports System.Web
Imports System.Data

Partial Class Consulta_AL_CursoActual_Anun
    Inherits System.Web.UI.Page
    Dim nCurGruCodigo As String

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Request.QueryString("nCurGruCodigo") Is Nothing Or Request.QueryString("nCurGruCodigo") Is String.Empty Then
            If Session("nCurGruCodigo") Is Nothing Or Session("nCurGruCodigo") Is String.Empty Then
                Response.Redirect("AL_InfoAcad_CA.aspx")
            Else
                nCurGruCodigo = Session("nCurGruCodigo")
            End If
        Else
            Session("nCurGruCodigo") = Request.QueryString("nCurGruCodigo")
            nCurGruCodigo = Request.QueryString("nCurGruCodigo")
        End If
        Response.Expires = -1
        Response.AddHeader("Pragma", "no-cache")
        Response.AddHeader("cache-control", "private")
        Response.CacheControl = "no-cache"
        lnkRegresar_3.HRef = "./AL_CursoActual.aspx?nCurGruCodigo=" + nCurGruCodigo
        lnkRegresar_4.HRef = "./AL_CursoActual.aspx?nCurGruCodigo=" + nCurGruCodigo

        If Not Page.IsPostBack Then
            CargarAnuncios()
            Using Seguridad As New BLL_Administracion
                Seguridad.Set_Transaccion_Insert(Nothing, 100401, IdentityUser.UserCode, My.Request.UserHostAddress.ToString, CrearXMLTransaccion("Consulta Pagina Movil", "/Pagina|" + My.Request.Url.Segments(My.Request.Url.Segments.Length - 1).ToString))
            End Using
        End If
    End Sub

    Private Sub CargarAnuncios()

        Dim DivAnuncios As New StringBuilder

        Dim ldrItem As New List(Of IDataReader)
        Using ObjPool As New PoolDbCommand()
            Dim ObjData As New DAL_Kiosco(ObjPool.Database)
            ObjPool.AddDbCommand(ObjData.Get_Anuncio_By_nCurGruCodigo(nCurGruCodigo), PoolDbCommand.PoolDbCommandResultType.Query)
            ObjPool.Pooling(Nothing, ldrItem, True)
        End Using

        While ldrItem(0).Read
            DivAnuncios.Append("<ul><li>")
            DivAnuncios.Append("<p><strong>" & ldrItem(0).Item("cDocObserv").ToString & "</strong></p><p style=""white-space:normal; text-align:justify;"">" & ldrItem(0).Item("tDocConContenido").ToString & "</p>")
            DivAnuncios.Append("<p class=""ui-li-aside"">" & ldrItem(0).Item("Dia").ToString & " de " & ldrItem(0).Item("Mes").ToString & "</p>")
            DivAnuncios.Append("<p>De:  <strong>" & ldrItem(0).Item("ALIAS").ToString & "</strong></p>")
            DivAnuncios.Append("</li></ul>")
        End While
        If DivAnuncios.ToString = "" Then
            DivAnuncios.Append("<p><strong>NO HAY ANUNCIOS</strong></p>")
        End If

        lblcontenido.Text = DivAnuncios.ToString
        ldrItem(0).Close()
        ldrItem = Nothing

    End Sub

End Class